<tagLib name="html" />

<div id="pm-container" class="container">
    <div id="msg-container">
        <h2 class="error-tips"></h2>
    </div>
    <form id="pm-form" method="POST" action="{:U('User/pm')}">
        <table class="tb" width="100%">
        	<tr>
                <td align="right"><label for="subject">{$Think.lang.subject}:</label></td>
                <td><input id="subject" class="input" name="subject" size="60" /></td>
            </tr>
            <tr>
                <td align="right" valign="top"><label for="message">{$Think.lang.message}:</label></td>
                <td><textarea id="message" class="textarea" name="message" rows="5" cols="80"></textarea><span id="message-counter" class="counter"></span></td>
            </tr>
            <eq name="captcha" value="1">
            <tr>
                <td align="right"><label for="verify">{$Think.lang.captcha}:</label></td>
                <td><div class="captcha-container"><input id="verify" class="input" type="text" name="verify" />&nbsp;<img class="captcha" src="{:U('Ajax/captcha')}" title="{$Think.lang.captcha_again}" onclick="reCaptcha(this);" /></div></td>
            </tr>
            </eq>
            <tr>
                <td align="right"><span id="waiting">{$Think.lang.email_sending}</span></td>
                <td>
                	<input id="pm-submit" class="button" type="button" value="{$Think.lang.submit}">
                	<input id="uid" type="hidden" name="uid" value="{$user.user_id}" />
                </td>
            </tr>
        </table>
    </form>
</div>

<load href="__PUBLIC__/Js/jquery.artTxtCount.js" />
<script type="text/javascript">
$(function(){
    $('#message').artTxtCount($('#message-counter'), 1500);
    $('#pm-submit').click(function(){
        var url = $('#pm-form').attr('action');
        var data = {
            uid: $('#uid').val(),
            subject: $('#subject').val(),
            message: $('#message').val(),
            verify: $('#verify').val()
        };
        $('#waiting').show();
        $.post(url, data, function(json){
            $('#waiting').hide();
            $('#msg-container').show();
            var json = eval('('+json+')');
            if(json.status == 0){
                $('#msg-container>h2').html(json.info);
                return false;
            }else{
                $('#msg-container>h2').attr('class','success-tips').html(json.info);
                $('#pm-submit').attr({disabled:true, class:'alt-button'});
                setTimeout(function(){
                    $.dialog.get(data.uid).close();
                }, WAIT_TIME);
            }
        });
        return false;
    });
});
</script>
